using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MusicManager : MonoBehaviour
{
    private static MusicManager instance;
    public static MusicManager Instance => instance;

    private AudioSource audioSource;

    private void Awake()
    {
        instance = this;
        audioSource = this.GetComponent<AudioSource>();
        
        //初始化音乐
        ChangeVolume(GameDataManager.Instance.musicData.musicValue);
        OpenOrCloseMusic(GameDataManager.Instance.musicData.isOpenMusic);
    }

    public void ChangeVolume(float value)
    {
        audioSource.volume = value;
    }

    public void OpenOrCloseMusic(bool isOpen)
    {
        audioSource.mute = !isOpen;
    }
}